package pl.easyshop.core.dao.common;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;


/**
 * Generic DAO interface.
 * 
 * @author Pawel Witkowski
 *
 * @param <T> - data model class
 */
public interface GenericDAO<E> {

	/**
	 * Load entity object.
	 * 
	 * @param id object identifier.
	 * 
	 * @return enity object.
	 */
	E load(Long id); 
	
	/**
	 * Persist model data.
	 * 
	 * @param model data model.
	 * 
	 * @return persist model identifier.
	 */
	Long save(E model);

	/**
	 * Update model data.
	 * 
	 * @param model data to update.
	 */
	void update(E model);

	/**
	 * Delete data model with given id.
	 * 
	 * @param id data model identifier.
	 */
	void delete(Long id);
	
	List<E> find(DetachedCriteria detachedCriteria, int firstResult, int maxResults);
	
	List<E> find(DetachedCriteria criteria);

}

